home *** CD-ROM | disk | FTP | other *** search
- Path: in2.uu.net!usc!usc!not-for-mail
- From: wawda@alcor.usc.edu (Abu Wawda)
- Newsgroups: comp.lang.c++
- Subject: Why Do Return Values Sometimes Have '&' Appended?
- Date: 21 Feb 1996 16:15:27 -0800
- Organization: University of Southern California, Los Angeles, CA
- Sender: wawda@alcor.usc.edu
- Distribution: world
- Message-ID: <4ggciv$iq1@alcor.usc.edu>
- NNTP-Posting-Host: alcor.usc.edu
-
- I have seen code where some of the functions are returned with the
- reference operator (&) attached to the end. Here is an example:
-
- MyReturn& MyFunction(...)
- {
- }
-
- I don't understand what that does. I have seen this most often in
- operator overloading such as:
-
- class MyClass
- {
- MyClass& operator + (MyClass&);
- }
-
- I understand why you the function parameter uses the & operator since
- you want to pass the class by reference, but why is it used in the
- return value? Thank you,
-
- Abu Wawda
- wawda@scf.usc.edu
-